package com.tang.client;

import com.tang.codec.ObjDecoder;
import com.tang.codec.ObjEncoder;
import com.tang.domain.FileTransferProtocol;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * 初始化Channel
 *
 * @author fulin.tang
 * @version V3.0
 * @since 2022/5/17 11:54
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new ObjDecoder(FileTransferProtocol.class));
        ch.pipeline().addLast(new ObjEncoder(FileTransferProtocol.class));
        // 在管道中加我们自己的接收数据实现方法
        ch.pipeline().addLast(new MyClientHandler());
    }

}
